package com.lwc.auto;

import com.auth0.jwt.JWT;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@AutoConfiguration//声明为自动配置类
@ConditionalOnClass(JWT.class) //判断是否有jwt类
@EnableConfigurationProperties(TokenProperties.class)//开启批量绑定
@ConditionalOnProperty(prefix = "token",value = "enable",matchIfMissing = true)//指定的属性是否有指定的值
public class TokenAutoConfig {


//注入tokenTemplate
          @Bean
          @ConditionalOnMissingClass
          public TokenTemplate tokenTemplate(){
    return  new TokenTemplate();
          }
}
